# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

require 'login_system'

class ApplicationController < ActionController::Base
    include LoginSystem
    
    layout "site"
    
    before_filter :get_account_from_session
    before_filter :load_site
    
    def get_account_from_session   
        account_id = @session['account']
        @account = Account.find_first(["id = ?", account_id]) 
    end
    
    def account_is_logged_in
        if @account == nil
            store_location
            redirect_to :controller => "account", :action => "login"
        end
    end
    
    def load_site
        @site = Site.find_by_directory(params[:site_directory])
    end
end